package com.mrzhou.thread.study;

import lombok.extern.slf4j.Slf4j;

/**
 * P24 线程常用方法Sleep_中断
 * @author qiang.zhou
 */
@Slf4j
public class P24ThreadSleepInterrupt {

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            log.info("start sleep....");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                log.error("interrupted 线程休眠被中断了...", e);
            }
            log.info("end sleep...");
        }, "t1");
        t.start();
        // main线程休眠1000毫秒
        Thread.sleep(1000);
        log.info("interrupt....");
        // 中断t1线程
        t.interrupt();
    }

}
